package com.geccocrawler.gecco.demo.hospital;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.JSONPath;
import com.geccocrawler.gecco.annotation.Request;
import com.geccocrawler.gecco.annotation.RequestParameter;
import com.geccocrawler.gecco.dynamic.DynamicGecco;
import com.geccocrawler.gecco.request.HttpPostRequest;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.spider.JsonBean;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:定点医疗机构
 * User: weixiaohu
 * Date: 2019/6/3
 * Time: 11:28
 */
@Getter
@Setter
@Gecco( matchUrl = "http://si.12333.gov.cn/118733/RemoteQuery003.jspx",pipelines = {"hospitalPipeline","consolePipeline"},timeout = 10000)
public class SpiderMain implements JsonBean{
    @Request
    private HttpRequest request;
    @JSONPath("$.lists.resultset.total")
    private int total;
    @JSONPath("$.lists.resultset.list")
    private List list;
    @RequestParameter("pageSize")
    private int pageSize;
    @RequestParameter("pageNo")
    private int pageNo;

    public static void main(String[] args) {
        DynamicGecco.json().gecco("http://si.12333.gov.cn/loadAdministrativeCode.jspx","areaPipeline")
                .requestField("request").request().build()
                .listField("list", Object.class).jsonpath("$.fieldData.codelist").build()
                .register();
        GeccoEngine.create()
                .classpath("com.geccocrawler.gecco.demo.hospital")
                .thread(3)
                .interval(2000)
                .start(new HttpPostRequest("http://si.12333.gov.cn/loadAdministrativeCode.jspx"))
                .run();

    }
}
